package com.wzcl.app.controller;

import com.wzcl.app.dao.model.TestPaper;
import com.wzcl.app.model.common.RVO;
import com.wzcl.app.model.dto.TestPaperDto;
import com.wzcl.app.model.vo.TestPaperVo;
import com.wzcl.app.service.TestPaperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * @author beingven
 * @Description TODO
 * @createTime 2021年01月06日 16:18:00
 */
@RestController
@RequestMapping("/testPaper")
@Api(value = "试卷相关controller", tags = {"试卷相关接口"})
public class TestPaperController {
    @Resource
    private TestPaperService testPaperService;

    @ApiOperation("添加/更新试卷")
    @PostMapping("/create")
    public RVO<TestPaper> createTestPaper(@RequestBody TestPaperDto testPaperDto){
        return RVO.success(testPaperService.createTestPaper(testPaperDto));
    }

    @ApiOperation("删除")
    @DeleteMapping("/delete")
    public RVO<TestPaperVo> deleteByIds(@RequestBody List<Integer> ids){
        return testPaperService.deleteByIds(ids);
    }

    @ApiOperation("根据学科、年级、名称、类型查询试卷")
    @PostMapping("/retrieve/condition")
    public RVO retrieveByCondition(@RequestBody TestPaperDto testPaperDto){
        return RVO.success(testPaperService.retrieveByCondition(testPaperDto));
    }

    @ApiOperation("根据id查询试卷")
    @GetMapping("/retrieve/{id}")
    public RVO retrieveById(@PathVariable Integer id){
        return RVO.success(testPaperService.retrieveById(id));
    }

    @ApiOperation("统计下载量接口")
    @PutMapping("/update/count/{id}")
    public RVO updateDownloadNumber(@PathVariable Integer id){
        return testPaperService.updateDownloadNumber(id);
    }


}